package com.lxy.exportword.service.impl;

import com.deepoove.poi.data.PictureRenderData;
import com.deepoove.poi.data.Pictures;
import com.lxy.exportword.entity.base.AbnormalSituationPoint;
import com.lxy.exportword.entity.base.AbnormalSituationPointReview;
import com.lxy.exportword.entity.base.RectificationStatisticsTable;
import com.lxy.exportword.entity.base.UavFlightRecordSheet;
import com.lxy.exportword.entity.moxi.*;
import com.lxy.exportword.entity.moxi.vo.HistoricalReviewRecordsVo;
import com.lxy.exportword.entity.moxi.vo.PipelineTypeVo;
import com.lxy.exportword.service.IMoXiService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.sound.midi.VoiceStatus;
import java.util.*;

/**
 * @author LiuXiaoYu
 * @date 2021/9/8- 15:23
 */
@Service
public class MoXiServiceImpl implements IMoXiService {


    @Value("${outFile.photoPath}")
    private String photoPath;

    /**
     * 示例
     * 获取磨溪前两页模板数据
     * @return
     */
    @Override
    public MoXiHeader getAllMoXiHeader() {
        return new MoXiHeader
                ("1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1");
    }

    /** 示例
     * 获取集输气干线的异常点情况(表格)
     * @return 返回List集合
     */
    @Override
    public List<GasGatheringTransmissionTrunkLine> getAllTableExceptions() {
        //1.从数据库查到了集气总干线的异常集合
        List<GasGatheringTransmissionTrunkLine> gasGatheringTransmissionTrunkLineList=new ArrayList<>();
        GasGatheringTransmissionTrunkLine line1 = new GasGatheringTransmissionTrunkLine("1","刘1","20.54（*1）","本次巡检无异常");
        GasGatheringTransmissionTrunkLine line2 = new GasGatheringTransmissionTrunkLine("2","刘2","21.54（*1）","新增异常点：遂宁市安居区磨溪镇，管线上方5米范围内有动土迹象。");
        GasGatheringTransmissionTrunkLine line3 = new GasGatheringTransmissionTrunkLine("3","刘3","20.54（*2）","新增异常点：①遂宁市安居区磨溪镇，管线上方5米范围内有动土迹象。\n" +
                "②遂宁市安居区磨溪镇，管线上方5米范围内有挖渠迹象。");
        GasGatheringTransmissionTrunkLine line4 = new GasGatheringTransmissionTrunkLine("4","刘4","20.54（*2）","本次巡检无异常");
        gasGatheringTransmissionTrunkLineList.add(line1);
        gasGatheringTransmissionTrunkLineList.add(line2);
        gasGatheringTransmissionTrunkLineList.add(line3);
        gasGatheringTransmissionTrunkLineList.add(line4);
        return gasGatheringTransmissionTrunkLineList;
    }
    /** 示例
     * 获取转注水干线的异常点情况(表格)
     * @return 返回List集合
     */
    @Override
    public List<TransferMainLineWaterInjection> getTransferMainLineWaterTableExceptions() {
        //1.从数据库查到了转注水干线的异常集合
        List<TransferMainLineWaterInjection> transferMainLineWaterInjectionList=new ArrayList<>();
        TransferMainLineWaterInjection line1 = new TransferMainLineWaterInjection("1","刘1","20.54（*1）","本次巡检无异常");
        TransferMainLineWaterInjection line2 = new TransferMainLineWaterInjection("2","刘2","21.54（*1）","新增异常点：遂宁市安居区磨溪镇，管线上方5米范围内有动土迹象。");
        TransferMainLineWaterInjection line3 = new TransferMainLineWaterInjection("3","刘3","20.54（*2）","新增异常点：①遂宁市安居区磨溪镇，管线上方5米范围内有动土迹象。\n" +
                "②遂宁市安居区磨溪镇，管线上方5米范围内有挖渠迹象。");
        TransferMainLineWaterInjection line4 = new TransferMainLineWaterInjection("4","刘4","20.54（*2）","本次巡检无异常");
        transferMainLineWaterInjectionList.add(line1);
        transferMainLineWaterInjectionList.add(line2);
        transferMainLineWaterInjectionList.add(line3);
        transferMainLineWaterInjectionList.add(line4);
        return transferMainLineWaterInjectionList;
    }

    @Override
    public List<AbnormalSituationPoint> getAllAbnormalSituationPointList() {
        //TODO 数据本来都是从数据库中查的 呵呵

         //封装磨溪异常记录表所有异常情况点的信息
        List<AbnormalSituationPoint> abnormalSituationPointList = new ArrayList<>();
        AbnormalSituationPoint abnormalSituationPoint = new AbnormalSituationPoint();
        //首先是标题 TODO 每个标签前面要根据这个List有几个变成(例子1.1.1/1.1.2/1.1.3之类的再加上问题描述)
        abnormalSituationPoint.setProblemDescription("一级异常情况点（动土）");
        //异常情况巡检图(不止一张) TODO 本来图片地址应该是从数据库中查出来的这只是模拟数据
        List<Map<String,PictureRenderData>> abnormalSituationInspectionChart=new ArrayList<>();
        Map<String,PictureRenderData> map=new HashMap<>();
        Map<String,PictureRenderData> map2=new HashMap<>();
        PictureRenderData inspectionChartOne = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/异常情况点/1.1异常情况巡检图(1).png").create();
        PictureRenderData inspectionChartTwo = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/异常情况点/1.1异常情况巡检图(2).png").create();
        map.put("abnormalSituationInspectionChart",inspectionChartOne);
        map2.put("abnormalSituationInspectionChart",inspectionChartTwo);

        abnormalSituationInspectionChart.add(map);
        abnormalSituationInspectionChart.add(map2);
        abnormalSituationPoint.setAbnormalSituationInspectionChart(abnormalSituationInspectionChart);
        //异常情况巡检图(不止一张) TODO 本来图片地址应该是从数据库中查出来的这只是模拟数据
        List<Map<String,PictureRenderData>> anomalyDistributionMap=new ArrayList<>();
        Map<String,PictureRenderData> map3=new HashMap<>();
        Map<String,PictureRenderData> map4=new HashMap<>();
        PictureRenderData anomalyDistributionMapOne = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/异常情况点/1.1异常情况分步图(1).png").create();
        PictureRenderData anomalyDistributionMapTwo = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/异常情况点/1.1异常情况分步图(2).png").create();
        map3.put("anomalyDistributionMap",anomalyDistributionMapOne);
        map4.put("anomalyDistributionMap",anomalyDistributionMapTwo);
        anomalyDistributionMap.add(map3);
        anomalyDistributionMap.add(map4);
        abnormalSituationPoint.setAnomalyDistributionMap(anomalyDistributionMap);

        //地点
        abnormalSituationPoint.setLocation("遂宁市安居区磨溪镇，距离龙王庙集气总站的直线距离约为4448米。");
        //坐标
        abnormalSituationPoint.setCoordinate("105.66637E、30.31133N");
        //TODO 管线类型 先不管不知道怎么做才好
        List<PipelineTypeVo> pipelineTypeVos=new ArrayList<>();
        pipelineTypeVos.add(new PipelineTypeVo("主线","干线"));
        abnormalSituationPoint.setPipelineType(pipelineTypeVos);
        //管线名称
        abnormalSituationPoint.setPipelineName("1-3#西眉清管站至龙王庙集气总站");
        //参考依据
        abnormalSituationPoint.setReference("《中华人民共和国石油天然气管道保护法》第三十条，在管道线路中心线两侧各五米地域范围内。");
        //情况说明
        abnormalSituationPoint.setDescriptionSituation("管线上方5米范围内有动土迹象。");
        /*-----------------------固定翼/多旋翼巡检-----------*/
        //巡检时间
        abnormalSituationPoint.setInspectionTime("07月22日19时16分");
        //无人机飞手
        abnormalSituationPoint.setDroneOperator("刘小余");
        //飞行高度
        abnormalSituationPoint.setFlyingHeight("100米");
        //焦距倍数
        abnormalSituationPoint.setFocalLength("33倍");
        //天气
        abnormalSituationPoint.setWeather("十分生气懂吗");
        //温度
        abnormalSituationPoint.setTemperature("100000度");

        /*-----------------------数据分析-----------------------*/
        //分析时间
        abnormalSituationPoint.setAnalysisTime("07月22日19时16分");
        //分析人员
        abnormalSituationPoint.setAnalysts("刘小余");
        /*-----------------------多旋翼排查----------------------*/
        //排查时间
        abnormalSituationPoint.setInvestigationTime("07月22日19时16分");
        //无人机飞手
        abnormalSituationPoint.setDronePilot("刘小余");
        //排查情况
        abnormalSituationPoint.setMultiRotorCheckSituation("哈哈哈哈哈哈哈哈哈哈");
        /*----------------------实地核查---------------------------*/
        //核查时间
        abnormalSituationPoint.setCheckTime("07月22日19时16分");
        //核查人员
        abnormalSituationPoint.setVerifier("刘小余");
        //核查情况
        abnormalSituationPoint.setFieldCheckSituation("管线上方5米范围内有动土迹象。");
        /*----------------------异常情况汇报-------------------------*/
        //汇报时间
        abnormalSituationPoint.setReportingTime("07月22日19时16分");
        //汇报人员
        abnormalSituationPoint.setReporter("刘小余");
        //甲方接收人
        abnormalSituationPoint.setRecipient("刘小余");
        //甲方答复
        abnormalSituationPoint.setReply("此处已与施工方确认，做了硬隔离。");
        //汇报证明  TODO 图像大小感觉需要用注解抽取
        List<Map<String,PictureRenderData>> reportCertificate=new ArrayList<>();
        Map<String,PictureRenderData> map5=new HashMap<>();
        Map<String,PictureRenderData> map6=new HashMap<>();
        PictureRenderData reportCertificateOne = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/异常情况点/1.1汇报证明.png").create();
        PictureRenderData reportCertificateTwo = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/异常情况点/1.1汇报证明.png").create();
        map5.put("reportCertificate",reportCertificateOne);
        map6.put("reportCertificate",reportCertificateTwo);
        reportCertificate.add(map5);
        reportCertificate.add(map6);
        abnormalSituationPoint.setReportCertificate(reportCertificate);

        abnormalSituationPointList.add(abnormalSituationPoint);
        abnormalSituationPointList.add(abnormalSituationPoint);
        abnormalSituationPointList.add(abnormalSituationPoint);
        return abnormalSituationPointList;
    }


    /**
     * 获取磨溪异常表的所有复查异常情况
     * @return List集合
     */
    @Override
    public List<AbnormalSituationPointReview> getAllAbnormalSituationPointReviewList() {
        //TODO 数据本来都是从数据库中查的 呵呵

        //封装磨溪异常记录表所有异常情况点的信息
        List<AbnormalSituationPointReview> abnormalSituationPointReviewList = new ArrayList<>();
        AbnormalSituationPointReview abnormalSituationPointReview = new AbnormalSituationPointReview();
        //首先是标题 TODO 每个标签前面要根据这个List有几个变成(例子2.2.1/2.2.2之类的再加上问题描述)
       abnormalSituationPointReview.setProblemDescription("一级异常情况点复查（管道裸露）");
        //首次发现情况图 TODO 本来图片地址应该是从数据库中查出来的这只是模拟数据
        List<Map<String,PictureRenderData>> firstFindSituationMap=new ArrayList<>();
        Map<String,PictureRenderData> map=new HashMap<>();
        PictureRenderData firstFindSituationMapOne = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/复查异常情况/2.1首次发现情况图.png").create();
        map.put("firstFindSituationMap",firstFindSituationMapOne);
        firstFindSituationMap.add(map);
       abnormalSituationPointReview.setFirstFindSituationMap(firstFindSituationMap);
        //最新复查情况图 TODO 本来图片地址应该是从数据库中查出来的这只是模拟数据
        List<Map<String,PictureRenderData>> latestReviewSituationMap=new ArrayList<>();
        Map<String,PictureRenderData> map3=new HashMap<>();
        PictureRenderData latestReviewSituationMapOne = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/复查异常情况/2.1最新复查情况图.png").create();
        map3.put("latestReviewSituationMap",latestReviewSituationMapOne);
        latestReviewSituationMap.add(map3);
       abnormalSituationPointReview.setLatestReviewSituationMap(latestReviewSituationMap);
        //地点
       abnormalSituationPointReview.setLocation("遂宁市安居区磨溪镇，距离龙王庙集气总站的直线距离约为4448米。");
        //坐标
       abnormalSituationPointReview.setCoordinate("105.66637E、30.31133N");
        //TODO 管线类型 先不管不知道怎么做才好
        List<PipelineTypeVo> pipelineTypeVos=new ArrayList<>();
        pipelineTypeVos.add(new PipelineTypeVo("干线","主线"));
        abnormalSituationPointReview.setPipelineType(pipelineTypeVos);
        //管线名称
       abnormalSituationPointReview.setPipelineName("1-3#西眉清管站至龙王庙集气总站");
        //参考依据
       abnormalSituationPointReview.setReference("《中华人民共和国石油天然气管道保护法》第三十条，在管道线路中心线两侧各五米地域范围内。");
        //情况说明
       abnormalSituationPointReview.setDescriptionSituation("管线上方5米范围内有动土迹象。");
       //多了一个首次发现时间
        abnormalSituationPointReview.setFirstDiscoveryTime("07月12日");

        /*-----------------又多了一个复查记录 根据List集合大小增加行数 ---------------------*/
        List<HistoricalReviewRecordsVo> historicalReviewRecords=new ArrayList<>();
        HistoricalReviewRecordsVo historicalReviewRecordsVoOne=new HistoricalReviewRecordsVo("2021年9月12日","没什么问题");
        historicalReviewRecords.add(historicalReviewRecordsVoOne);
        historicalReviewRecords.add(historicalReviewRecordsVoOne);
        historicalReviewRecords.add(historicalReviewRecordsVoOne);
        abnormalSituationPointReview.setHistoricalReviewRecords(historicalReviewRecords);

        /*-----------------------本次固定翼/多旋翼复查----------------------*/
        //巡检时间
        abnormalSituationPointReview.setInspectionTime("07月22日19时16分");
        //无人机飞手
        abnormalSituationPointReview.setDroneOperator("刘小余");
        //飞行高度
        abnormalSituationPointReview.setFlyingHeight("100米");
        //焦距倍数
        abnormalSituationPointReview.setFocalLength("33倍");
        //天气
        abnormalSituationPointReview.setWeather("十分生气懂吗");
        //温度
        abnormalSituationPointReview.setTemperature("100000度");


        /*-----------------------数据分析-----------------------*/
        //分析时间
       abnormalSituationPointReview.setAnalysisTime("07月22日19时16分");
        //分析人员
       abnormalSituationPointReview.setAnalysts("刘小余");
        /*----------------------实地核查---------------------------*/
        //核查时间
       abnormalSituationPointReview.setCheckTime("07月22日19时16分");
        //核查人员
       abnormalSituationPointReview.setVerifier("刘小余");
        //核查情况
       abnormalSituationPointReview.setFieldCheckSituation("管线上方5米范围内有动土迹象。");
        /*----------------------异常情况汇报-------------------------*/
        //汇报时间
       abnormalSituationPointReview.setReportingTime("07月22日19时16分");
        //汇报人员
       abnormalSituationPointReview.setReporter("刘小余");
        //甲方接收人
       abnormalSituationPointReview.setRecipient("刘小余");
        //甲方答复
       abnormalSituationPointReview.setReply("此处已与施工方确认，做了硬隔离。");
        //汇报证明  TODO 图像大小感觉需要用注解抽取
        List<Map<String,PictureRenderData>> reportCertificate=new ArrayList<>();
        Map<String,PictureRenderData> map5=new HashMap<>();
        PictureRenderData reportCertificateOne = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/复查异常情况/2.1汇报证明.png").create();
        map5.put("reportCertificate",reportCertificateOne);
        reportCertificate.add(map5);
       abnormalSituationPointReview.setReportCertificate(reportCertificate);

       abnormalSituationPointReviewList.add(abnormalSituationPointReview);
       abnormalSituationPointReviewList.add(abnormalSituationPointReview);
       abnormalSituationPointReviewList.add(abnormalSituationPointReview);
        return abnormalSituationPointReviewList;
    }

    /**附件1
     * 获取磨溪异常点整改情况统计所有信息
     * @return List集合
     */
    @Override
    public List<RectificationStatisticsTable> getAllRectificationStatistics() {
        List<RectificationStatisticsTable> list=new ArrayList<>();
        list.add(new RectificationStatisticsTable("1","1","1","1","1","1","1","1","1"));
        list.add(new RectificationStatisticsTable("1","1","1","1","1","1","1","1","1"));
        list.add(new RectificationStatisticsTable("1","1","1","1","1","1","1","1","1"));
        return list;
    }

    /**附件2
     * 获取磨溪无人机飞行记录表所有信息
     * @return List集合
     */
    @Override
    public UavFlightRecordSheet getAllUavFlightRecord() {
        UavFlightRecordSheet uavFlightRecordSheet = new UavFlightRecordSheet();
         List<Map<String,PictureRenderData>> uavFlightRecordList=new ArrayList<>();
        Map<String,PictureRenderData> map=new HashMap<>();
        Map<String,PictureRenderData> map2=new HashMap<>();
        Map<String,PictureRenderData> map3=new HashMap<>();
        PictureRenderData uavFlightRecordSheetOne = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/附件2无人机飞行记录表/无人机飞行记录表1.png").create();
        PictureRenderData uavFlightRecordSheetTwo = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/附件2无人机飞行记录表/无人机飞行记录表2.png").create();
        PictureRenderData uavFlightRecordSheetThree = Pictures.ofLocal(photoPath + "磨溪（07.21-07.27）/附件2无人机飞行记录表/无人机飞行记录表3.png").create();
        map.put("uavFlightRecordSheet",uavFlightRecordSheetOne);
        map2.put("uavFlightRecordSheet",uavFlightRecordSheetTwo);
        map3.put("uavFlightRecordSheet",uavFlightRecordSheetThree);
        uavFlightRecordList.add(map);
        uavFlightRecordList.add(map2);
        uavFlightRecordList.add(map3);
        uavFlightRecordSheet.setUavFlightRecordSheet(uavFlightRecordList);
        return uavFlightRecordSheet;
    }
}
